package com.yt.db.constant;


import com.yt.common.utils.StrUtils;

/**
 * @Description ：
 * @Author ：闾泽明
 * @Date ： 2017/09/12 15:22
 */
public enum DataSourceEnum {
    dataSourceWirte("DATA_SOURCE_WIRTE", "主库", "wirte"),
    dataSourceRead("DATA_SOURCE_READ", "从库", "read")
    ;

    private String code;
    private String msg;
    private String app_key;
    DataSourceEnum(String code, String msg, String app_key) {
        this.code = code;
        this.msg = msg;
        this.app_key = app_key;
    }

    public static DataSourceEnum get(String app_key){
        DataSourceEnum dataEnum = DataSourceEnum.dataSourceWirte;
        if(StrUtils.isNotEmpty(app_key)){
            for (DataSourceEnum ds: DataSourceEnum.values()) {
                if(app_key.equals(ds.app_key)){
                    dataEnum = ds;
                    break;
                }
            }
        }
        return dataEnum;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getApp_key() {
        return app_key;
    }

    public void setApp_key(String app_key) {
        this.app_key = app_key;
    }
}
